﻿Public Class Form1

    Dim log As log4net.ILog

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        log = log4net.LogManager.GetLogger("MyApp")


        '*http://stackoverflow.com/questions/1930083/log4net-configuration-exception
        '*If you have your config in a separate log4net.config file you don't need the sectionHandler. Remove it.
        '*You() 're also probably calling XmlConfigurator.Configure() somewhere in your code. Remove that as well.

        '*log4net.Config.XmlConfigurator.Configure()
    End Sub

    Private Sub btnDebug_Click(sender As System.Object, e As System.EventArgs) Handles btnDebug.Click
        log.Debug("'Debug' level message")
    End Sub

    Private Sub btnInfo_Click(sender As System.Object, e As System.EventArgs) Handles btnInfo.Click
        log.Info("'Info' level message")
    End Sub

    Private Sub btnWarning_Click(sender As System.Object, e As System.EventArgs) Handles btnWarning.Click
        log.Warn("'Warning' level message")
    End Sub

    Private Sub btnError_Click(sender As System.Object, e As System.EventArgs) Handles btnError.Click
        log.Error("'Error' level message")
    End Sub

    Private Sub btnFatal_Click(sender As System.Object, e As System.EventArgs) Handles btnFatal.Click
        log.Fatal("'Fatal' level message")
    End Sub
End Class
